<?php
/**
 * 旁站记录
 * @author ZhouYP
 **/

namespace Admin\Controller;
use Common\Controller\WahahabaseController;
class SupervisionSideReportController extends WahahabaseController{
    protected $deal_model;
	public function _initialize() {
		parent::_initialize();
		$this->deal_model = D("Common/SupervisionSideReport");
		$this->dept_model = D("Common/Department");
		$this->att_model = D("Common/Attachment");
		$this->check = array('code');
	}
	/**
     *  主页
     */
	public function index(){
		/**搜索条件**/
		$where = array("d.is_deleted"=>array('neq', 1));
		$side_position = trim(I('request.side_position'));
		if($side_position){
			$where['side_position'] = array('like',"%$side_position%");
		}
        $this->getDepartLevel();
        $this->indexPage($where);
	}

	/**
     *  添加旁站记录
     */
	public function add(){
		$depts = $this->dept_model->field("id,department_name")->where(array('is_deleted' => array('neq', 1),'department_role' => 5))->select();
		$this->assign("depts", $depts);
		$this->display();
	}
    public function add_post(){

		$this->addFilePost(U("SupervisionSideReport/index"), 13);
	}
	/**
     *  修改
     */
	public function edit(){
			$id = I('get.id',0,'intval');
			$data = $this->deal_model->where(array("id"=>$id))->find();
			$this->assign("data", $data);
			$depts = $this->dept_model->field("id,department_name")->where(array('is_deleted' => array('neq', 1),'department_role' => 5))->select();
			$this->assign("depts", $depts);	
			$results = $this->att_model->where(array("table_id" => $id, "belong_to" => 13))->select();
        	$this->assign("results", $results);	
		    $this->display();
	}
	public function edit_post(){
		
			$this->editFilePost(U("SupervisionSideReport/index"), 13);
	}
	
   public function  view(){
	 $id = I('get.id',0,'intval');
	 $data = $this->deal_model->where(array("id"=>$id))->find();
	 $this->assign("data",$data);
	 $this->getDepartLevel();
	 $results = $this->att_model->where(array("table_id" => $id, "belong_to" => 13))->select();
     $this->assign("results", $results);
	 $this->display();
    }
}


?>